/**
 * 设计图px宽度转换为vw,高度转换为vh
 */

import { Dimensions } from 'react-native';

const screenWidth = Dimensions.get('window').width;
const screenHeight = Dimensions.get('window').height;

// UI设计图宽度
const UIWidthPx = 393;

// UI设计图高度
const UIHeightPx = 850;

// 设计图元素px宽度转换为vw,uiWidthPx为UI设计图宽度,默认为393px
const pxToVw = (uiElementPx: number, uiWidthPx: number = UIWidthPx) => {
  return (uiElementPx * screenWidth) / uiWidthPx;
};

// 设计图元素px高度转换为vh,uiHeightPx为UI设计图高度,默认为850px
const pxToVh = (uiElementPx: number, uiHeightPx: number = UIHeightPx) => {
  return (uiElementPx * screenHeight) / uiHeightPx;
};

export { pxToVh, pxToVw, screenWidth, screenHeight };
